home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / science / sm32a.zip / SYMBMATH.H05 < prev    next >
Text File  |  1993-11-15  |  8KB  |  181 lines

  1.             3.1.  Data Types
  2.     The data types in SymbMath language is the numbers, constants, 
  3. variables, functions, equations, arrays, array index, lists, list index,
  4. and strings. All data can be operated. It is not necessary to declare
  5. data to be which type, as SymbMath can recognize it.
  6.  
  7.             3.1.1  Numbers
  8.     The types of numbers are integer, rational, real (floating-point), 
  9. and complex numbers in the range from -infinity to infinity. 
  10.     In fact, the range of the input real numbers is 
  11. -inf, -(10^307)^(10^307) to -(10^-307)^(10^-307), 0, (10^-307)^(10^-307)
  12.  to (10^307)^(10^307), inf.
  13.     The range of the output real numbers is the same as input 
  14. when the switch numeric:=off, but when the switch numeric:=on, it is
  15.     -inf, -1.E307 to -1.E-307, 0, 1.E-307 to 1.E307, inf.
  16.     It means that the number larger than 1.e307 is converted 
  17. automatically to inf, the absolute values of the number less than 
  18. 1.e-307 is converted to 0, and the number less than -1e307 is 
  19. converted to -inf.
  20.  
  21.     For examples:
  22. -------------------------------------------
  23. Numbers         Type
  24.  
  25. 23              integer
  26. 2/3             rational
  27. 0.23            real
  28. 2.3E2           real 
  29. 2+3*i           complex
  30. 2.3+i           complex
  31. ---------------------------------------------
  32.  
  33.  
  34. That "a" and "b" are the same means a-b = 0, while that they are 
  35. different means a-b <> 0. 
  36.     For the real numbers, the upper and lower case letters E 
  37. and e in exponent are the same, e.g. 1e2 is the same as 1E2.
  38.  
  39.  
  40.         3.1.2.  Constants 
  41.  
  42.     The constants are the unchangeable values. There are some 
  43. built-in constants. The name of these built-in constants should be 
  44. avoided in the user-defined constants.
  45.  
  46. ------------------------------------------------------------------
  47. Built-in Constants      Meanings
  48.  
  49. pi:=3.1415926536        the circular constant.
  50. e:=2.7182818285         the base of the natural logarithms.
  51. i:=sqrt(-1)             the imaginary sign of complex numbers.
  52. inf                     infinity.
  53. -inf                    negative infinity.
  54. c_inf                   complex infinity, both real and imaginary parts
  55.             of complex numbers are infinity. e.g. inf+inf*i.
  56. constant                the integral constant.
  57. discont                 discontinuity, e.g. 1/0. 
  58.             (You can evaluate the one-
  59.             sided value by x=x0+zero or x0-zero if the 
  60.             value of expression is discont).
  61. x0-zero                 to evaluate left-sided value when x approach x0 
  62.             from negative (-inf) direction, as zero -> 0.
  63. x0+zero                 to evaluate right-sided value when x approach x0 
  64.             from positive (+inf) direction, as zero -> 0.
  65. undefined               the undefined value, e.g. indeterminate forms:
  66.             0/0, inf/inf, 0*inf, 0^0, etc.
  67. --------------------------------------------------------------------
  68.  
  69. Zero is the positive-directed 0, as the built-in constant. f(x0+zero)  
  70. is the right-hand sided function value when x approaches to x0 from the
  71. positive direction, i.e. x = x0+. f(x0-zero) is the left-sided function
  72. value when x approaches to x0 from the negative direction, i.e. x = x0-.
  73. e.g. f(1+zero) is the rigth-hand sided function value when x approaches 
  74. to 1 from the positive (+infinity) direction, i.e. x = 1+, f(1-zero) is
  75. the left-hand sided function value when x approaches to 1 from the negative
  76. (-infinity) direction, i.e. x = 1-; exp(1/(0+zero)) gives inf,
  77. exp(1/(0-zero)) gives 0.
  78.         The inf, discont and undefined can be computed as if numbers.
  79.  
  80.         Example.
  81. IN:  inf+2, discont+2, undefined+2
  82. OUT: inf, discont, undefined
  83.  
  84.     Notice that the discont and undefined constants are
  85. different. If the value of an expression at x=x0 is discont, the
  86. expression only has the one-sided value at x=x0 and this one-sided 
  87. value is evaluated by x=x0+zero or x=x0-zero. If the value of an 
  88. expression at x=x0 is undefined, the expression may be evaluated by 
  89. the function lim(). 
  90.  
  91.     Example 3.1.1. evaluate exp(1/x) and sin(x)/x at x=0.
  92.  
  93. IN:  f(x_) := exp(1/x)
  94. OUT: f(x_) := exp(1/x)
  95. IN:  f(0)
  96. OUT: discont            # f(0) is discontinuty, only has one sided value
  97. IN:  f(0+zero)          # right-sided value
  98. OUT: inf
  99. IN:  f(0-zero)          # left-sided value
  100. OUT: 0
  101.  
  102. IN:  subs(sin(x)/x, x = 0)
  103. OUT: undefined
  104. IN:  lim(sin(x)/x, x = 0)     # it is evaluated by lim()
  105. OUT: 1
  106.  
  107.  
  108.         3.1.3.  Variables
  109.  
  110.     The sequence of characters is used as the name of variables. 
  111. Variable names can be up to 128 characters long. They must begin with a
  112. letter and use only letters and digits.  SymbMath knows upper and lower
  113. case distinctions in variable names, so AB, ab, Ab and aB are the
  114. different variables. They are case sensitive until the switch lowercase is
  115. set to on (i.e. lowercase:=on).
  116.      Variables can be used to store the results of calculations.
  117. Once a variable is defined, it can be used in another formula.  Having
  118. defined X as above, you could define Y := ASIN(X).  You can also redefine a
  119. variable by storing a new value in it.  If you do this, you will lose the
  120. original value entirely.
  121.          Assign a result to a variable, just put
  122.       <var-name> :=  expression
  123. e.g.               a := 2 + 3      # assign value to a
  124.       Variables can be used like constants in expressions.
  125. For example:
  126.                a := 2 + 3
  127.                b := a*4
  128.       If an undefined variable is used in an expression, then the
  129. expression returns a symbolic result (which may be stored in another
  130. variable).  Pick an undefined variable name, say x, and enter:
  131.  
  132.                y := 3 + x  # formula results since x undefined
  133.                x := 4      # Now x is defined
  134.                y           # y returns 7, but its value is
  135.                    # still the formula 3 + x
  136.                x := 7      # revalue x
  137.                y           # new value for y
  138.  
  139.     Note that in symbolic computation, the variable has not only a
  140. numeric value but also a symbolic value.
  141.     Symbolic values for variables are useful mostly for viewing 
  142. the definitions of functions and symbolic differentiation and 
  143. integration.
  144.     Watch out for infinite recursion here.  Defining
  145.                x := x+3
  146. when x has no initial value, it will not cause an immediate problem,
  147. but any future reference to x  will result in an infinite recursion !
  148.     A value can be assigned to the variable, by one of three methods:
  149. (1) the assignment :=, 
  150. (2) the user-defined function f(), 
  151. (3) subs(y, x = x0).
  152.  
  153. e.g. 
  154. y:=x^2
  155. x:=2                    # assignment
  156. y
  157. f(2)                    # if f(x) has been defined, e.g. f(x_):=x^2.
  158. subs(x^2, x = 2)        # evaluate x^2 when x = 2.
  159.     The variable named last is the built-in as the variable last is
  160. always automatically assigned the value of the last output result.
  161.         The usual used independent variable is x.
  162.         By default, |x| < inf and all variables are complex, except that
  163. variables in inequalities are real, as usual only real numbers can be
  164. compared. e.g. x is complex in sin(x), but y is real in y > 1.
  165.     You can restrict the domain of a variable by assuming the variable
  166. is even, odd, integer, real number, positive or negative (see Chapter 4.2
  167. Simplification and Assumption).
  168.  
  169.  
  170.         3.1.4  Patterns
  171.     Patterns stand for classes of expressions.
  172.  
  173. _       any expression.
  174. x_      any expression, given the name x.
  175.  
  176. Patterns should appear on the left-hand side of the assignment only,
  177. not on the right-hand side of the assignment. Patterns are only used in
  178. definition of functions, procedures and rules.
  179.         Patterns in SymbMath language are similar with patterns in such
  180. language as MATHEMATICA.
  181.